"""
套餐变更类相关接口
包含单卡可变更套餐、变更提交、用户池套餐变更、订单查询、变更记录查询等接口方法。
"""
from .api_utils import md5, get_tkey, post_api

def card_change_package_query(userName, passWord, iccid):
    """查询单卡可变更套餐接口"""
    url = "https://api.tibiot.com/api/v1/queryUpdatePackage"
    tKey = get_tkey()
    pw = md5(md5(passWord) + tKey)
    data = {"userName": userName, "passWord": pw, "tKey": tKey, "iccid": iccid}
    return post_api(url, data)

def card_change_package_submit(userName, passWord, iccid, packageId):
    """单卡变更套餐提交接口"""
    url = "	https://api.tibiot.com/api/v1/submitCardUpdatePackage"
    tKey = get_tkey()
    pw = md5(md5(passWord) + tKey)
    data = {"userName": userName, "passWord": pw, "tKey": tKey, "iccid": iccid, "packageId": packageId}
    return post_api(url, data)

def user_pool_change_package_query(userName, passWord, poolId):
    """查询用户池可变更套餐接口"""
    url = "https://api.tibiot.com/api/v1/queryPoolUpdatePackage"
    tKey = get_tkey()
    pw = md5(md5(passWord) + tKey)
    data = {"userName": userName, "passWord": pw, "tKey": tKey, "poolId": poolId}
    return post_api(url, data)

def user_pool_change_package_submit(userName, passWord, poolId, packageId):
    """用户池变更套餐提交接口"""
    url = "	https://api.tibiot.com/api/v1/submitPoolUpdatePackage"
    tKey = get_tkey()
    pw = md5(md5(passWord) + tKey)
    data = {"userName": userName, "passWord": pw, "tKey": tKey, "poolId": poolId, "packageId": packageId}
    return post_api(url, data)

def change_package_order_query(userName, passWord, orderId):
    """变更套餐订单查询接口"""
    url = "	https://api.tibiot.com/api/v1/queryUpdatePackageOrder"
    tKey = get_tkey()
    pw = md5(md5(passWord) + tKey)
    data = {"userName": userName, "passWord": pw, "tKey": tKey, "orderId": orderId}
    return post_api(url, data)

def card_change_record_query(userName, passWord, iccid):
    """卡变更记录查询接口"""
    url = "	https://api.tibiot.com/api/v1/queryCardChangeRecord"
    tKey = get_tkey()
    pw = md5(md5(passWord) + tKey)
    data = {"userName": userName, "passWord": pw, "tKey": tKey, "iccid": iccid}
    return post_api(url, data)
